<?php
require_once (SITEBASE."system/db/dbconnect.class.php");
class DbPromo extends Connection
{

	
	
	
	function addPromotion( $sql, $sectorId){
	
		//$sql = "INSERT INTO `aramark`.`categories` VALUES ('', '".$sectorId."',  '".$categoryName."');";
 		$result = $this->selectQuery($sql);
 		
 		if ($result){
 		header("Location:index.php?act=displaycurrentcategories&sector=".$sectorId."");
 		}
	}
	
	
	function updateCategory( $categoryName, $sectorId, $id){
	
		$sql = "UPDATE `categories` SET `nameOfCategory` = '".$categoryName."' WHERE `categories`.`id` = ".$id." LIMIT 1 ;";
 		$result = $this->selectQuery($sql);
 		
 		if ($result){
 		// index.php?act=displaycurrentcategories&sector=1
 		header("Location:index.php?act=displaycurrentcategories&sector=".$sectorId."");
 		}
	}
	function addSubCategory($sql){
		$result = $this->selectQuery($sql);
	}
	
	function deleteCategory( $id , $sectorId){
	
		$sql = "DELETE FROM `categories` WHERE `id` = ".$id.";";
 		$result = $this->selectQuery($sql);
 		
 		if ($result){
 		header("Location:index.php?act=displaycurrentcategories&sector=".$sectorId."");
 		}
	}
	
	function selectPromotions($sectorId, $categoryId){
		$sql = "SELECT * FROM `promotions` WHERE `sector` = ".$sectorId." AND `category` = ".$categoryId.";";
		$result = $this->selectQuery($sql);
		return $result;
	}
	
	function selectPromo($id){
		$sql = "SELECT * FROM `promotions` WHERE `id` = ".$id.";";
		$result = $this->selectQuery($sql);
		return $result;
	
	}
	
	function getSubCategoryTitle($id){
		$sql = "SELECT * FROM `subcategories` WHERE `id` = ".$id.";";
		$result = $this->selectQuery($sql);
		$titleArray = mysql_fetch_array($result);
		$title = $titleArray['title'];
		return $title;
	}
	
	
}
	
?>